<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>大马驮2石粮食，中马驮1石粮食，两头小马驮一石粮食，要用100匹马，驮100石粮食，该如何调配</title>
</head>

<body>
    <script>
        var large = 2;
        var middle = 1;
        var small = 0.5;
        // 100/2=50;100/1=100;100/0.5=200
        for (var a = 0; a <= 50; a++) {
            for (var b = 0; b <= 100; b++) {
                var c = ((100 - a - b) % 2 == 0 ? (100 - a - b) : false);
                if (c && a * large + b * middle + c * small === 100 && a + b + c === 100) {
                    console.log(a + "头大马, " + b + "头中马, " + c + "头小马");
                }
            }
        }
        var big =2;
        for(big=1;big<=50;big++){//12
            for(middle = 1;middle<=100;middle++)//1 2
                for(small=1;small<=200;small++){//12345
                if (big+middle + small === 100 && big *2 +middle *1+ small *.5 ===100){
                console.log('大马：'+big+',中马：'+middle+',小马：'+small);
                }
            }
        }
                
    </script>

</body>

</html>